#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    vector<string> commonChars(vector<string>& words)
    {
        int m = words.size();
        vector<vector<int>> hash(m, vector<int>(26));
        vector<string> ret;
        for (int i = 0; i < words.size(); i++)
        {
            for (int j = 0; j < words[i].size(); j++)
            {
                hash[i][words[i][j] - 'a']++;
            }
        }

        for (int j = 0; j < 26; j++)
        {
            int minval = 100;

            for (int i = 0; i < words.size(); i++)
            {
                minval = min(minval, hash[i][j]);
            }

            while (minval--)
            {
                ret.push_back(string(1, j + 'a'));
            }
        }
        return ret;

    }
};